﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BusinessComponents;
using DataAccessLayer;

namespace PresentationLayerMVC.Controllers
{
    public class RoomTypeController : Controller
    {

        BusinessComponentsFacade facade = new BusinessComponentsFacade();
        HRSEntities modelContext = new HRSEntities();
        //
        // GET: /RoomType/
        [OutputCache(Duration=3600, VaryByParam="None")]
        public ActionResult Index()
        {
            //IEnumerable<RoomType> roomTypes = modelContext.RoomTypes;
            IEnumerable<RoomType> roomTypes = facade.findAllRoomType();
            return View(roomTypes);
        }

        //
        // GET: /RoomType/Details/5

        public ActionResult Details(int id)
        {
            RoomType roomType = modelContext.RoomTypes.SingleOrDefault(m => m.ID == id);
            return View(roomType);
        }

        //
        // GET: /RoomType/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /RoomType/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /RoomType/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /RoomType/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /RoomType/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /RoomType/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
